from django.conf.urls import url, include
from django.contrib import admin
from rest_framework import routers
from rest_framework.routers import SimpleRouter
from rest_framework_jwt.views import obtain_jwt_token

from sadmin.views.admin_view import AdminView
from sadmin.views.brands_views import BrandViewSet
from sadmin.views.channel_views import ChannelViewSet, ChannelGroupView
from sadmin.views.image_views import SKUImageViewSet
from sadmin.views.options_views import OptionsViews, SpecSimpleView
from sadmin.views.orders_view import OrderInfoViewSet
from sadmin.views.permission_view import PermissionView, GroupViewSet
from sadmin.views.sku_views import SKUSetView, SKUCategorieView, SPUSimpleView, SPUSpecOptView
from sadmin.views.specs_views import SpecsViews
from sadmin.views.spu_views import SPUGoodsView, BrandSimpleView, ChannelCategoryView
from sadmin.views.user_views import UserView
from sadmin.views.home_views import HomeView
from sadmin.views.log_views import  AdminLoginView
from . import views
urlpatterns = [
    # SKU表管理
    url(r'^skus/$', SKUSetView.as_view({"get": "list", "post": "create"})),
    url(r'^skus/(?P<pk>\d+)/$', SKUSetView.as_view({"get": "retrieve",
                                                    "delete": "destroy",
                                                    "put": "update"})),
    # 获得新建sku可选三级分类

    url(r'authorizations/$', obtain_jwt_token),
    url(r'users/$', UserView.as_view()),
    url(r'skus/categories/$', SKUCategorieView.as_view()),
    url(r'goods/$', SPUGoodsView.as_view({"get":'list','post':'create'})),
    url(r'goods/(?P<pk>\d+)/$', SPUGoodsView.as_view({"get": 'retrieve','put':'update','delete':'destroy'})),
    # url(r'goods/undefined/$', SPUGoodsView.as_view({'put':'update'})),

    url(r'goods/specs/$', SpecsViews.as_view({'get':'list','post':'create'})),
    url(r'goods/specs/(?P<pk>\d+)/$', SpecsViews.as_view({'get': 'retrieve','put':'update','delete':'destroy'})),

    url(r'specs/options/$', OptionsViews.as_view({'get':'list','post':'create'})),
    url(r'specs/options/(?P<pk>\d+)/$', OptionsViews.as_view({'get':'list','delete':'destroy','put':'update'})),

    url(r'goods/specs/simple/$', SpecSimpleView.as_view({'get': 'list'})),

    url(r'goods/simple/$', SPUSimpleView.as_view()),
    url(r'goods/brands/simple/$', BrandSimpleView.as_view()),

    # url(r'goods/channel/categories/$', ChannelCategoryView.as_view({'get':'list'})),
    # url(r'^goods/channel/categories/(?P<pk>\d+)/$', ChannelCategoryView.as_view({'get':'list'})),
    url(r'skus/images/$', SKUImageViewSet.as_view({'get':'list','post':'create'})),
    url(r'skus/images/(?P<pk>\d+)/$', SKUImageViewSet.as_view({'get': 'retrieve','delete':'destroy','put':'update'})),
    # url(r'skus/simple/$', SKUSimpleViewSet.as_view({'get':'list'})),
    url(r'skus/simple/$', SKUImageViewSet.as_view({'get':'get_simple'})),
    # 订单模块
    url(r'orders/$', OrderInfoViewSet.as_view({'get': 'list'})),
    url(r'orders/(?P<pk>\d+)/status/$', OrderInfoViewSet.as_view({'patch': 'patch_data'})),
    url(r'orders/(?P<pk>\d+)/$', OrderInfoViewSet.as_view({'get': 'get_orders'})),

    # 权限管理
    url(r'permission/perms/$', PermissionView.as_view({'get': 'list','post':'create'})),
    url(r'permission/perms/(?P<pk>\d+)/$', PermissionView.as_view({'get': 'retrieve','delete':'destroy','put':'update'})),
    url(r'permission/groups/$',GroupViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'permission/groups/(?P<pk>\d+)/$', GroupViewSet.as_view({'get':'retrieve','put':'update','delete':'destroy'})),
    url(r'permission/groups/simple/$', GroupViewSet.as_view({'get': 'notpage'})),
    url(r'permission/simple/$', PermissionView.as_view({'get': 'get_simple'})),
    url(r'permission/admins/$', AdminView.as_view({'get': 'list','post':'create'})),
    url(r'permission/admins/(?P<pk>\d+)/$', AdminView.as_view({'get':'retrieve','put':'update','delete':'destroy'})),

    url(r'goods/(?P<pk>\d+)/specs/$', SPUSpecOptView.as_view()),
    # url(r"^meiduo_admin/autho rizations/$",SPUSimpleView.as_view()),
    # url(r'^goods/channels/(?P<pk>\d+)/$', ChannelViewSet.as_view({"delete": "destroy",
    #                                                               "get": "retrieve",

    # url(r'^goods/channels/$', ChannelViewSet.as_view({"get":"list", "post":"create"})),

    # 新建频道可选一级分类信息
    # url(r'^goods/categories/$', ChannelCategoryView.as_view()),
    # 新建频道可选分组信息
    # url(r'^goods/channel_types/$', ChannelGroupView.as_view()),

    # 频道管理
    # 频道管理
    url(r'^goods/channels/$', ChannelViewSet.as_view({"get": "list", "post": "create"})),
    url(r'^goods/channels/(?P<pk>\d+)/$', ChannelViewSet.as_view({"delete": "destroy",
                                                                  "get": "retrieve",
                                                                  "put": "update"})),
    # 频道管理
    # 品牌表管理
    url(r'^goods/brands/$', BrandViewSet.as_view({"get": "list", "post": "create"})),
    url(r'^goods/brands/(?P<pk>\d+)/$', BrandViewSet.as_view({"get": "retrieve"})),

                                                              # 新建频道可选一级分类信息
    url(r'^goods/categories/$', SKUCategorieView.as_view()),
    # 新建频道可选分组信息
    url(r'^goods/channel_types/$', ChannelGroupView.as_view()),

]
router = SimpleRouter()
router.register(prefix='statistical', viewset=HomeView, base_name="home")

# router.register(prefix='skus', viewset=SKUSetView, base_name="sku")

# router_log = SimpleRouter()
# router.register(prefix='meiduo_admin', viewset=AdminLoginView, base_name="log")
# urlpatterns+=router_log.urls

urlpatterns += router.urls
